<?php defined('SYSPATH') OR die('No direct access allowed.');
 class Cms_Controller extends Website_Controller {
	const ALLOW_PRODUCTION = FALSE;

	 public $template = 'template/template';
	 public function __construct()
	 {
		parent::__construct();
		$this->profile = new Profile_Model();
		$this->model = new Cms_Model();

		$mes = Kohana::config('users_config.session_message');
		$this->not_authro = $mes["noacces"];
		$this->page_notfound = $mes["notfound"];
		$this->user_id = $this->session->get('userid');
		$user_id = $this->session->get('userid');
		$this->module = "cms";
	 }

		// function to display update 
		public function index()
		{ 
			$page = $this->input->get('page');
			$this->page = $this->model->get_page($page);
			if(count($this->page)) { 
				$title = ucfirst($this->page["mysql_fetch_array"]->cms_title);
				$this->template->title = $title;
				$this->title_content = $title;
				$this->template->content = new View("page");
			}
			else{
				Nauth::setMessage(-1,$this->page_notfound);
				url::redirect($this->docroot.'profile/');  
			}
		}
	   
	   //search form
	   public function commonsearch()
	   {
			$this->template->profile_info = $this->profile->profile_info($this->userid);
			$searchtext = $this->input->get('search_value');
			$this->page = $this->model->get_text($searchtext);
			$this->template->title = "Search Results";
			$this->title_content = "Search Results";
			$this->left = new View("profile/profile_left");
			$this->right = new View("page");
			$this->template->content = new View("/template/template2");
	   }

	public function __call($method, $arguments)
	{
	        
		// Disable auto-rendering
		$this->auto_render = FALSE;
		// By defining a __call method, all pages routed to this controller
		// that result in 404 errors will be handled by this method, instead of
		// being displayed as "Page Not Found" errors.
		echo 'This text is generated by __call. If you expected the index page, you need to use: forum/index/'.substr(Router::$current_uri, 8);
	}
}